package com.sgs.preorder.domain.service.impl;

import com.sgs.preorder.domain.client.ReportClient;
import com.sgs.preorder.domain.dto.CreateOrderCmd;
import com.sgs.preorder.domain.dto.OrderDetailDTO;
import com.sgs.preorder.domain.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sgs.preorder.domain.client.ReportSimplifyDTO;

import java.util.UUID;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author tim_tian
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private ReportClient reportClient;

    @Override
    public OrderDetailDTO getOrderDetail(String orderNo) {
        OrderDetailDTO orderDetailDTO = new OrderDetailDTO();
        orderDetailDTO.setOrderNo(orderNo);

        String reportNo = orderNo + UUID.randomUUID().toString();
        ReportSimplifyDTO reportSimplify = reportClient.getReportSimplify(reportNo);
        orderDetailDTO.setReportSimplifyDTO(reportSimplify);
        return orderDetailDTO;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void createOrder(CreateOrderCmd createOrderCmd) {

    }


}
